home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 21
/
Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso
/
Aminet
/
util
/
cdity
/
availmem2.lha
/
AvailMem2
/
src
/
AvailMem2_mdisp.s
< prev
next >
Wrap
Text File
|
1997-07-01
|
6KB
|
251 lines
machine 68020
* program includes
include "AvailMem2_gui.i"
include "AvailMem2.i"
include "lvo.i"
incdir "include:"
include "exec/types.i"
include "exec/funcdef.i"
include "intuition/intuition.i"
* program menu defines
MENU_PRJ_ABOUT equ $f800
MENU_PRJ_HIDE equ $f840
MENU_PRJ_QUIT equ $f860
MENU_STS_RESIZE equ $f801
MENU_STS_MODIFYST equ $f841
MENU_STS_LOADST equ $f881
MENU_STS_SAVEST equ $f8a1
MENU_STS_DEFAULTS equ $f8c1
MENU_NOPICK equ $ffff
section code,code ;availmem code section
_HandleMemoryDisplayMsgs
* * * * * * * * * * * * * * * * * * * * *
* *
* Handles memory-display msgs. *
* *
* * * * * * * * * * * * * * * * * * * * *
movem.l d0-a6,-(sp) ;push all registers
clr.l .prg_MemDisplayClose ;reset window close variable
clr.l .prg_SettingsChanged ;reset settings variable
tst.l MemoryDisplayWnd ;check if memory-display window open
beq .no_MemoryDisplayWnd ;skip if not
.MsgLoop_MemoryDisplay
move.l _GadToolsBase,a6 ;put gadtoolsbase in a6
move.l MemoryDisplayWnd,a0 ;get ptr to memory-display window
move.l wd_UserPort(a0),a0 ;get window userport
jsr _LVOGT_GetIMsg(a6) ;get any waiting message
move.l d0,ptr_TempMsg ;store msg
beq .no_MemoryDisplayWnd ;if no message, continue looping
move.l ptr_TempMsg,a4 ;put msg in a4
move.l im_Class(a4),d4 ;get msg class
cmp.l #IDCMP_CLOSEWINDOW,d4 ;check if closegadget was pressed
bne .not_IDCMP_CLOSEWINDOW ;skip if not
st.l prg_Terminate ;enable program termination
clr.l d4 ;reset msg class
.not_IDCMP_CLOSEWINDOW
cmp.l #IDCMP_CHANGEWINDOW,d4 ;check if window-position changed or if we were re-organized
bne .not_IDCMP_CHANGEWINDOW ;skip if not
move.l MemoryDisplayWnd,a0 ;put ptr to mem-display window in a4
move.w wd_LeftEdge(a0),MemoryDisplayLeft
move.w wd_TopEdge(a0),MemoryDisplayTop
move.w wd_Width(a0),MemoryDisplayWidth
move.w wd_Height(a0),d0
move.b wd_BorderTop(a0),d1
ext.w d1
sub.w d1,d0
move.w d0,MemoryDisplayHeight
clr.l d4 ;reset msg class
.not_IDCMP_CHANGEWINDOW
cmp.l #IDCMP_MENUPICK,d4 ;check if menu-item picked
bne .not_IDCMP_MENUPICK ;skip if not
move.w im_Code(a4),d4 ;put menu selected in d4
cmp.w #MENU_PRJ_ABOUT,d4 ;check if Menu About was selected
bne .no_MENU_PRJ_ABOUT ;skip if not
lea.l _AboutBody,a0 ;get about-body text into a0
lea.l _AboutGadgets,a1 ;get about-gadget text into a1
jsr _ProgramRequest ;create a program requester
.no_MENU_PRJ_ABOUT
cmp.w #MENU_PRJ_HIDE,d4 ;check if Menu Hide was selected
bne .no_MENU_PRJ_HIDE ;skip if not
st.l .prg_MemDisplayClose ;set window close variable
clr.l d4 ;clear msg class
.no_MENU_PRJ_HIDE
cmp.w #MENU_PRJ_QUIT,d4 ;check if Menu Quit was selected
bne .no_MENU_PRJ_QUIT ;skip if not
st.l prg_Terminate ;set program termination variable
clr.l d4 ;clear msg class
.no_MENU_PRJ_QUIT
cmp.w #MENU_STS_RESIZE,d4 ;check if Menu ReSize was selected
bne .no_MENU_STS_RESIZE ;skip if not
tst.l ResizeWnd ;check if already open
bne .no_MENU_STS_RESIZE ;skip if so
* install the memdisplay window into resize window
move.w MemoryDisplayLeft,ResizeLeft
move.w MemoryDisplayTop,ResizeTop
move.w MemoryDisplayWidth,ResizeWidth
move.w MemoryDisplayHeight,ResizeHeight
jsr OpenResizeWindow ;open availmem resize window
tst.l d0 ;check if window opened ok
bne .Fail ;bail out if failure
jsr CloseMemoryDisplayWindow;close main window
bra .no_MemoryDisplayWnd
clr.l d4 ;clear msg class
.no_MENU_STS_RESIZE
cmp.w #MENU_STS_MODIFYST,d4 ;check if Menu Modify was selected
bne .no_MENU_STS_MODIFYST ;skip if not
tst.l SettingsWnd ;check if already open
bne .SettingsWinOpen ;skip if so
jsr OpenSettingsWindow ;open availmem settings window
tst.l d0 ;check if window opened ok
bne .Fail ;bail out if failure
.SettingsWinOpen
move.l _IntuitionBase,a6 ;put intuitonbase in a6
move.l SettingsWnd,a0 ;put settingswindow in a0
jsr _LVOActivateWindow(a6) ;activate window
jsr _SetSettingsGadgets ;install program preferences
clr.l d4 ;clear msg class
.no_MENU_STS_MODIFYST
cmp.w #MENU_STS_LOADST,d4 ;check if Menu Load was selected
bne .no_MENU_STS_LOADST ;skip if not
jsr _LoadMainPreferences ;load new preferences
move.l d0,.prg_SettingsChanged ;set/clr settings variable
clr.l d4 ;clear msg class
.no_MENU_STS_LOADST
cmp.w #MENU_STS_SAVEST,d4 ;check if Menu Save was selected
bne .no_MENU_STS_SAVEST ;skip if not
jsr _SaveMainPreferences ;save program preferences
clr.l d4 ;clear msg class
.no_MENU_STS_SAVEST
cmp.w #MENU_STS_DEFAULTS,d4 ;check if Menu Reset was selected
bne .no_MENU_STS_DEFAULTS ;skip if not
jsr _ResetToDefaults
st.l .prg_SettingsChanged
clr.l d4 ;clear msg class
.no_MENU_STS_DEFAULTS
clr.l d4 ;clear msg class
.not_IDCMP_MENUPICK
cmp.w #IDCMP_GADGETUP,d4
bne .no_IDCMP_GADGETUP
move.l (4).w,a6 ;flush memory
move.l #$3000000,d0
clr.l d1
jsr _LVOAllocVec(a6)
move.l d0,a1
beq .MemNotAllocated
jsr _LVOFreeVec(a6)
.MemNotAllocated
.no_IDCMP_GADGETUP
move.l _GadToolsBase,a6 ;put gadtoolsbase in a6
move.l ptr_TempMsg,a1 ;put tempmsg in a1
jsr _LVOGT_ReplyIMsg(a6) ;reply window msg
bra .MsgLoop_MemoryDisplay ;loop message-reader
.no_MemoryDisplayWnd
tst.l .prg_MemDisplayClose ;check if win should close
beq .no_MemDisplayClose ;skip if it shouldn't
jsr _CloseGUI ;close program GUI
.no_MemDisplayClose
tst.l .prg_SettingsChanged ;check if settings has changed
beq .no_NewSettings ;skip if no new settings
jsr _CloseGUI ;close program GUI
jsr _RetrieveSettings ;get the new settings into action
jsr _OpenGUI ;open program GUI up again
tst.l d0 ;check if opening succeded
beq .Fail ;bail out if failure
.no_NewSettings
movem.l (sp)+,d0-a6 ;pop all registers
clr.l d0 ;set exitcode to FALSE
rts ;return
.Fail
movem.l (sp)+,d0-a6 ;pop all registers
st.l d0 ;set exitcode to TRUE
rts ;return
.prg_MemDisplayClose ds.l 1
.prg_SettingsChanged ds.l 1
section data,data ;availmem data section
* Menu about text
_AboutBody dc.b "AvailMem v2.0 Copyright © 1996-1997 Jesper Svennevid\n\n"
dc.b "This program is email-ware, so if you use it, please\n"
dc.b "send me an email: chip@beer.com\n\n"
dc.b "Registered to: UNREGISTERED VERSION",0
_AboutGadgets dc.b "Ok",0